package com.rmy.queue.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.rmy.common.annotation.Log;
import com.rmy.common.core.controller.BaseController;
import com.rmy.common.core.domain.AjaxResult;
import com.rmy.common.enums.BusinessType;
import com.rmy.queue.domain.QmsPublishRecord;
import com.rmy.queue.service.IQmsPublishRecordService;
import com.rmy.common.utils.poi.ExcelUtil;
import com.rmy.common.core.page.TableDataInfo;

/**
 * 发布记录Controller
 * 
 * @author rmy
 * @date 2022-11-11
 */
@RestController
@RequestMapping("/queue/pubrecord")
public class QmsPublishRecordController extends BaseController
{
    @Autowired
    private IQmsPublishRecordService qmsPublishRecordService;

    /**
     * 查询发布记录列表
     */
    @PreAuthorize("@ss.hasPermi('queue:pubrecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(QmsPublishRecord qmsPublishRecord)
    {
        startPage();
        List<QmsPublishRecord> list = qmsPublishRecordService.selectQmsPublishRecordList(qmsPublishRecord);
        return getDataTable(list);
    }

    /**
     * 导出发布记录列表
     */
    @PreAuthorize("@ss.hasPermi('queue:pubrecord:export')")
    @Log(title = "发布记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QmsPublishRecord qmsPublishRecord)
    {
        List<QmsPublishRecord> list = qmsPublishRecordService.selectQmsPublishRecordList(qmsPublishRecord);
        ExcelUtil<QmsPublishRecord> util = new ExcelUtil<QmsPublishRecord>(QmsPublishRecord.class);
        util.exportExcel(response, list, "发布记录数据");
    }

    /**
     * 获取发布记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('queue:pubrecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(qmsPublishRecordService.selectQmsPublishRecordById(id));
    }

    /**
     * 新增发布记录
     */
    @PreAuthorize("@ss.hasPermi('queue:pubrecord:add')")
    @Log(title = "发布记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QmsPublishRecord qmsPublishRecord)
    {
        return toAjax(qmsPublishRecordService.insertQmsPublishRecord(qmsPublishRecord));
    }

    /**
     * 修改发布记录
     */
    @PreAuthorize("@ss.hasPermi('queue:pubrecord:edit')")
    @Log(title = "发布记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QmsPublishRecord qmsPublishRecord)
    {
        return toAjax(qmsPublishRecordService.updateQmsPublishRecord(qmsPublishRecord));
    }

    /**
     * 删除发布记录
     */
    @PreAuthorize("@ss.hasPermi('queue:pubrecord:remove')")
    @Log(title = "发布记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(qmsPublishRecordService.deleteQmsPublishRecordByIds(ids));
    }
}
